package com.tools.web.interceptor.quota;

import com.tools.common.object.Note;

import java.util.Objects;

/**
 * 配额限制拦截器所需的参数配置项的包装类实例
 * */
@Note("配额限制拦截器所需的参数配置项的包装类实例")
public class QuotaSource {

    @Note("缓存 key 的前缀，后续拼接上 uniqueID 作为 key")
    private String cachePrefix;

    @Note("到达额度后响应给客户端的提示信息")
    private String responseMessage;

    @Note("没有找到 UniqueID 参数所响应的异常信息")
    private String notHasUniqueIDErrorMessage;

    public QuotaSource() {}

    public static QuotaSource of() {
        return new QuotaSource();
    }

    public String getCachePrefix() {
        return cachePrefix;
    }

    public void setCachePrefix(String cachePrefix) {
        this.cachePrefix = cachePrefix;
    }

    public String getResponseMessage() {
        return responseMessage;
    }

    public void setResponseMessage(String responseMessage) {
        this.responseMessage = responseMessage;
    }

    public String getNotHasUniqueIDErrorMessage() {
        return notHasUniqueIDErrorMessage;
    }

    public void setNotHasUniqueIDErrorMessage(String notHasUniqueIDErrorMessage) {
        this.notHasUniqueIDErrorMessage = notHasUniqueIDErrorMessage;
    }

    @Override
    public String toString() {
        return "QuotaSource{" +
                "cachePrefix='" + cachePrefix + '\'' +
                ", responseMessage='" + responseMessage + '\'' +
                ", notHasUniqueIDErrorMessage='" + notHasUniqueIDErrorMessage + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        QuotaSource that = (QuotaSource) o;
        return Objects.equals(cachePrefix, that.cachePrefix);
    }

    @Override
    public int hashCode() {
        return Objects.hash(cachePrefix);
    }


    public QuotaSource cachePrefix(String cachePrefix) {
        this.setCachePrefix(cachePrefix);
        return this;
    }

    public QuotaSource responseMessage(String responseMessage) {
        this.setResponseMessage(responseMessage);
        return this;
    }

    public QuotaSource notHasUniqueIDErrorMessage(String notHasUniqueIDErrorMessage) {
        this.setNotHasUniqueIDErrorMessage(notHasUniqueIDErrorMessage);
        return this;
    }
}
